﻿using PHMEE.ToolKits;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE.Entities.BaseInfo.Units
{
    /// <summary>
    /// 主机机组
    /// </summary>
    public class MainEngineUnit : Unit
    {
        protected MainEngineUnit()
        {

        }
        public MainEngineUnit(Guid id, Guid vesselId, string name, string nameen, int number) : base(id, vesselId, name, nameen, number)
        {

        }


        /// <summary>
        /// 透平端速度rms阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double TrmsA { get; set; }

        /// <summary>
        /// 透平端速度rms阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double TrmsB { get; set; }

        /// <summary>
        /// 透平端速度rms阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double TrmsC { get; set; }

        /// <summary>
        /// 速度谱1x频幅值
        /// 1
        /// </summary>
        [NotMapped]
        public double TValue1XA { get; set; }

        /// <summary>
        /// 速度谱1x频幅值
        /// 2
        /// </summary>
        [NotMapped]
        public double TValue1XB { get; set; }


        /// <summary>
        /// 结构松动故障判断阈值
        /// </summary>
        [NotMapped]
        public double TStructureLoose { get; set; }

        /// <summary>
        /// 共振故障判断阈值
        /// </summary>
        [NotMapped]
        public double TResonanceFault { get; set; }

        /// <summary>
        /// 叶轮故障判断阈值
        /// </summary>
        [NotMapped]
        public double TImpellerFault { get; set; }

        /// <summary>
        /// 不平衡判断阈值
        /// </summary>
        [NotMapped]
        public double TImbalanceFault { get; set; }

        /// <summary>
        /// 轴瓦磨损故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double TAxleWearA { get; set; }

        /// <summary>
        /// 轴瓦磨损故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double TAxleWearB { get; set; }


        /// <summary>
        /// 轴瓦磨损故障判断阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double TAxleWearC { get; set; }


        /// <summary>
        /// 轴瓦磨损故障判断阈值
        /// 4
        /// </summary>
        [NotMapped]
        public double TAxleWearD { get; set; }


        /// <summary>
        /// 轴瓦磨损故障判断阈值
        /// 5
        /// </summary>
        [NotMapped]
        public double TAxleWearE { get; set; }


        /// <summary>
        /// 轴瓦磨损故障判断阈值
        /// 6
        /// </summary>
        [NotMapped]
        public double TAxleWearF { get; set; }


        /// <summary>
        /// 轴瓦磨损故障判断阈值
        /// 7
        /// </summary>
        [NotMapped]
        public double TAxleWearG { get; set; }

        /// <summary>
        /// 旋转失速/喘振类故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double TRotationalStallOrSurgeA { get; set; }

        /// <summary>
        /// 旋转失速/喘振类故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double TRotationalStallOrSurgeB { get; set; }


        public override void SerializeProperties(Dictionary<string, object> derivedPropertiesJson)
        {
            var properties = PHMEECoreHelper.GetDerivedProperties(this);
            this.DerivedPropertiesJson = derivedPropertiesJson.Where(item => properties.Keys.Any(p => string.Equals(p, item.Key, StringComparison.OrdinalIgnoreCase))).ToDictionary();
        }

        public override void DeserializeProperties()
        {
            PHMEECoreHelper.SetDerivedProperties(this, DerivedPropertiesJson);
        }

        public override Dictionary<string, object> InitDefaultProperties()
        {
            Dictionary<string, object> dict = new Dictionary<string, object>
            {
                { nameof(TrmsA), 7.1 },
                { nameof(TrmsB), 7.1 },
                { nameof(TrmsC), 7.1 },
                { nameof(TValue1XA), 30 },
                { nameof(TValue1XB), 30 },
                { nameof(TStructureLoose), 0.7 },
                { nameof(TResonanceFault), 0.7 },
                { nameof(TImpellerFault), 0.7 },
                { nameof(TImbalanceFault), 0.7 },
                { nameof(TAxleWearA), 0.6 },
                { nameof(TAxleWearB), 0.3 },
                { nameof(TAxleWearC), 0.3 },
                { nameof(TAxleWearD), 0.3 },
                { nameof(TAxleWearE), 0.4 },
                { nameof(TAxleWearF), 0.3 },
                { nameof(TAxleWearG), 0.3 },
                { nameof(TRotationalStallOrSurgeA), 0.6 },
                { nameof(TRotationalStallOrSurgeB), 0.6 }
            };

            return dict;

        }
    }
}
